function download_sensaris_files(options)
% SENSARIS - Download data files from sensor microSD card
% through Bluetooth serial connection.
%
% Usage:
%   download_sensaris_files(??);
%

%% connect to the sensor device 

% serial port

%For write operation
serobjw = serial('COM5') ;           % Creating serial port object now its connected to COM7

%Set connection properties
serobjw.Baudrate = 115200;      % Set the baud rate at the specific value
set(serobjw, 'Parity', 'none') ;     % Set parity as none
set(serobjw, 'Databits', 8) ;        % set the number of data bits
set(serobjw, 'StopBits', 1) ;        % set number of stop bits as 1
set(serobjw, 'Terminator', 'LF') ; % set the terminator value to newline

%set(serobjw, 'OutputBufferSize', 512) ;               % Buffer for write operation, default it is 512
get(serobjw);       


try
    fopen(serobjw) ;
    get(serobjw, 'Status')                 % Gets the status of connection if 'open' 
    set(serobjw, 'Timeout', 1) ;
    disp('suspend cmd...');
    disp('BytesToOutput');
    serobjw.BytesToOutput
%    fprintf(serobjw, 'suspend\n') ;
    disp('ValuesSent');
    serobjw.ValuesSent
    disp('BytesToOutput');
    serobjw.BytesToOutput
    disp('LIST cmd...');
    fprintf(serobjw, 'LIST\n') ;
    % reading 
    disp('reading data...');
    set(serobjw, 'Timeout', 2) ;
   
    for i=1:20
        disp('ValuesReceived');
        serobjw.ValuesReceived
        [A,count,msg] = fscanf(serobjw, '%c');
        disp('count:');
        count
        disp('msg:');
        msg
        disp('DATA:');
        A
    end

catch
    disp('error catch');
    lasterror
end

disp('Close serial port');
fclose(serobjw);

%% get file list





%% FUNCTIONS
%
% Usage:
% serobj=open_serial();
% test_serial(serobj);
% file_list=get_file_list(serobj);
% filename=file_list(1).filename;
% content=get_file_content(filename);
% disp(content);
% close_serial(serobj);

function serobj=open_serial()
serobj=0;

function test_serial(serobj)
disp('testing serial');

function close_serial(serobj)
disp('closed');

function file_list=get_file_list(serobj)
metadata.filename = filename;
metadata.date=0;
file_list=[metadata];

function content=get_file_content(filename)
content='';



